from django import template
from django.utils.encoding import force_text
from django.utils.safestring import mark_safe
import markdown2

register = template.Library()

@register.filter
def custom_cut(val, n):
    return val[:n]

@register.filter
def custom_cut2(val):
    return val[8:]

@register.filter
def custom_markdown(value):
    return mark_safe(markdown2.markdown(force_text(value),
        extras=["fenced-code-blocks", "cuddled-lists", "metadata", "tables", "spoiler"]))


